package com.weibo.fenx.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;

import com.weibo.common.BaseSeverlet;
import com.weibo.fenx.Fenx;
import com.weibo.fenx.service.FenxService;
import com.weibo.fenx.service.imp.FenxServiceImp;

public class FenxSaveServlet extends BaseSeverlet {
	private static Logger logger = Logger.getLogger(FenxSaveServlet.class);

	@Override
	public void doService(HttpServletRequest request,
			HttpServletResponse response) {
		logger.info("直发ZhifaSaveServlet被请求了！");

		HttpSession session = request.getSession();
		Fenx fenx = (Fenx) session.getAttribute("fenx");
		fenx.setTas_state("草稿");
		FenxService fenxservice = new FenxServiceImp();
		if (fenxservice.addFenx(fenx)) {
			try {
				request.getRequestDispatcher("/Task_add_share_confirm.jsp")
						.forward(request, response);
			} catch (ServletException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		} else {
			try {
				request.getRequestDispatcher("/Task_add_straight.jsp").forward(
						request, response);
			} catch (ServletException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

}
